import { createSlice } from '@reduxjs/toolkit'

export const TodoSlice = createSlice({
    // 命名空间，在调用action的时候会默认的设置为action的前缀,保证唯一.不重名
    name: 'todo',
    initialState: {
        dataAll:[
            { year: "2019", data: [200, 300, 300, 900, 1500, 1200, 600, 800, 1200, 1500, 500, 1600] },
            { year: "2020", data: [300, 400, 350, 800, 1800, 1400, 700, 400, 1500, 1300, 1900, 400] }
        ],


    },
    reducers: {
        // 定义的action-赋值的方式进行数据的改变
        // userChange: (state, action) => {
        //     state.user = { ...state.user, ...action.payload }
        // },
    },
})

// 导出action
// export const { userChange } = TodoSlice.actions

// 异步数据处理
// export const incrementAsync = (amount) => (dispatch) => {
//     setTimeout(() => {
//         dispatch(incrementByAmount(amount))
//     }, 1000)
// }

// export const selectCount = (state) => state.counter.value

// 导出reducer
const TodoSliceReducer = TodoSlice.reducer
export default TodoSliceReducer